﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common.Entitys.Messages
{
    [Serializable]
    public class MqttMsg
    {
        /// <summary>
        /// 对象
        /// </summary>
        public object Obj;

        /// <summary>
        /// 不序列化以节约开支
        /// </summary>
        [NonSerialized]
        public string TypeID;

        /// <summary>
        /// ID
        /// </summary>
        public string ClientId;

        public MqttMsg(object obj)
        {
            if (obj == null)
            {
                return;
            }

            if (!obj.GetType().IsSerializable)
            {
                throw new Exception($"{obj.GetType().Name} 未标记为可序列化");
            }
            Obj = obj;
        }
    }
}
